package br.ufpe.cin.dsoa.manager;

import java.util.HashMap;
import java.util.Map;

public class InvocationEvent {
	private String consumerId;
	private String providerId;
	private String operationName;
	private long   correlationId;
	private long startTime;
	private long stopTime;
	private Map<String, Object> attributes;
	
	@SuppressWarnings("rawtypes")
	private Class[] parameterTypes;
	private Object[] parameterValues;
	private String returnType;
	private Object returnValue;
	private String exceptionClass;
	private String exceptionMessage;
	private String rootCauseClass;
	private String rootCauseMessage;
	
	private InvocationEvent(String providerId,
			String operationName, 
			Class[] parameterTypes,
			Object[] parameterValues,
			long startTime, long stopTime) {
		this.providerId = providerId;
		this.operationName = operationName;
		this.parameterTypes = parameterTypes;
		this.parameterValues = parameterValues;
		this.attributes = new HashMap<String, Object>();
		this.startTime = startTime;
		this.stopTime = stopTime;
	}

	public InvocationEvent(String providerId,
			String operationName, 
			Class[] parameterTypes,
			Object[] parameterValues, String exceptionClass,
			String exceptionMessage, String rootCauseClass,
			String rootCauseMessage, long startTime, long stopTime) {
		this(providerId, operationName, parameterTypes, parameterValues, startTime, stopTime);
		this.exceptionClass = exceptionClass;
		this.exceptionMessage = exceptionMessage;
		this.rootCauseClass = rootCauseClass;
		this.rootCauseMessage = rootCauseMessage;
	}

	public InvocationEvent(String providerId,
			String operationName, 
			Class[] parameterTypes,
			Object[] parameterValues, String returnType,
			Object returnValue, 
			long startTime,
			long stopTime) {
		this(providerId, operationName, parameterTypes, parameterValues, startTime, stopTime);
		this.returnType = returnType;
		this.returnValue = returnValue;
	}

	public void setConsumerId(String id) {
		this.consumerId = id;
	}
	
	public void setCorrelationId(long id) {
		this.correlationId = id;
	}
	
    public void putAttribute(String name, Object value) {
        this.attributes.put(name, value);
    }
    
    public Object getAttribute(String name) {
        return this.attributes.get(name);
    }

	public String getReturnType() {
		return returnType;
	}

	public Object getReturnValue() {
		return returnValue;
	}

	public Class[] getParameterTypes() {
	    return parameterTypes;
	}

	public Object[] getParameterValues() {
	    return parameterValues;
	}

	public String getExceptionClass() {
		return exceptionClass;
	}

	public String getExceptionMessage() {
		return exceptionMessage;
	}

	public String getRootCauseClass() {
		return rootCauseClass;
	}

	public String getRootCauseMessage() {
		return rootCauseMessage;
	}

	public String getConsumerId() {
		return consumerId;
	}

	public String getProviderId() {
		return providerId;
	}

	public String getOperationName() {
		return operationName;
	}

	public long getCorrelationId() {
		return correlationId;
	}

	public Map<String, Object> getAttributes() {
		return attributes;
	}

	public long getStartTime() {
		return startTime;
	}

	public long getStopTime() {
		return stopTime;
	}
	
}
